package com.dxysun.jvm.entity;


public class Foo {
    private int tryBlock;
    private int catchBlock;
    private int finallyBlock;
    private int methodExit;

    public void test() {
        try {
            tryBlock = 0;
        } catch (Exception e) {
            catchBlock = 1;
        } finally {
            finallyBlock = 2;
        }
        methodExit = 3;
    }

    public static int bitCount(int i) {
        // HD, Figure 5-2
        i = i - ((i >>> 1) & 0x55555555);
        i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
        i = (i + (i >>> 4)) & 0x0f0f0f0f;
        i = i + (i >>> 8);
        i = i + (i >>> 16);
        return i & 0x3f;
    }
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
//        System.out.println(start);
        int sum = 0;
        for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
//            sum += bitCount(i); // In a second run, replace with Integer.bitCount
            sum += Integer.bitCount(i); // In a second run, replace with Integer.bitCount
        }
        System.out.println(sum);
        long end = System.currentTimeMillis();

        long cost = end - start;
        System.out.println(cost);
    }
}
